package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.StaffBean;
import com.project.mapper.IStaffMapper;
import com.project.service.IStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class StaffServiceImpl implements IStaffService {
    @Autowired
    private IStaffMapper mapper;
    @Override
    public PageInfo<StaffBean> findByItem(Integer pageNo,
    String name, String expertise, String state, String sort) {
        PageHelper.startPage(pageNo,4);
        return PageInfo.of(mapper.findByItem(name,expertise,state,sort));
    }

    @Override
    public void add(StaffBean staffBean) {

        mapper.add(staffBean);
    }

    @Override
    public void updateState(Integer id) {

        mapper.updateState(id, LocalDate.now());
    }

    @Override
    public void update(Integer id, String phone, Integer salary) {

        mapper.update(id,phone,salary);
    }

    @Override
    public StaffBean findByIdProject(Integer id) {
        return mapper.findByIdProject(id);
    }

    @Override
    public StaffBean findById(Integer id) {
        return mapper.findById(id);
    }

    @Override
    public List<StaffBean> findByNoItem(String name, String expertise, Integer projId) {
        return mapper.findByNoItem(name,expertise,projId);
    }
}
